<?php echo $header; ?>
  <link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/catethanh.css" />
        <script type="text/javascript" src="catalog/view/theme/default/js/common.js"></script>
       <div class="cate">
    <div class="content">
        <div class="content-left">
            <div class ="cld-search">
                <div class="cld-title">
                    <span><?php echo $heading_title; ?></span>
                    <div class="clearfix"></div>
                </div>
                <?php if ($categories) { ?>
                <?php if (count($categories) <= 5) { ?>
                <ul class="cld-item">
                    <?php foreach ($categories as $category) { ?>
                    <li><a href="<?php echo $category['href']; ?>"><span><?php echo $category['name']; ?></span></a></li>
                    <?php } ?>
                </ul>
                <?php } else { ?>
                <?php for ($i = 0; $i < count($categories);$i ++) { ?>
                <ul class="cld-item">
                    <?php $j = $i + ceil(count($categories) / 4); ?>
                    <?php for (; $i < $j; $i++) { ?>
                    <?php if (isset($categories[$i])) { ?>
                    <li><a href="<?php echo $categories[$i]['href']; ?>"><span><?php echo $categories[$i]['name']; ?></span></a></li>
                    <?php } ?>
                    <?php } ?>
                </ul>
                <?php } ?>
                <?php } ?>
                <?php } ?>
                <div class="clear"></div>
                <div class="cld-search-title">Lọc theo tên sản phẩm</div>
                <div class="cld-table">
                    <table border="1px" cellpadding="1px" cellspacing="1px">
                        <tr><td class="select"><a type="button" name="filter_name" value="A">A</a>/></td><td>B</td><td>C</td><td>D</td><td>E</td><td>G</td><td>H</td></tr>
                        <tr><td>I</td><td>J</td><td class="select">K</td><td class="select">L</td><td>M</td><td>N</td><td>O</td></tr>
                        <tr><td>P</td><td>Q</td><td>R</td><td>S</td><td>T</td><td>U</td><td>V</td></tr>
                        <tr><td>W</td><td>X</td><td>Y</td><td>Z</td><td></td><td></td><td></td></tr>
                    </table>
                </div>
            </div>
            <div class="clear"></div>
            <ul class="left-item member">
                <li><a href="#"><img src="image/data/images/member.png" /></a></li>
                <li><a href="#"><img src="image/data/images/chef.png" /></a></li>
                <li><a href="#"><img src="image/data/images/imgad1.png" /></a></li>
                <li><a href="#"><img src="image/data/images/imgad2.png" /></a></li>
            </ul>
        </div>
        <div class="content-right">
            <div class="center">
                <div class="navigate">
                    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
                    <?php echo $breadcrumb['separator']; ?><a class="ngv-home" href="<?php echo $breadcrumb['href']; ?>"><span><?php echo $breadcrumb['text']; ?></span></a>
                    <?php } ?>
                </div><!-- end navigete -->
                <div class="frmname">
                    <?php echo $heading_title; ?>
                </div>
                <div class="page">
                    <?php echo $pagination; ?>
                </div>
                <div class="page-line"></div>
                <div class="clear"></div>
                <table class="search-kt" border="1px" cellpadding="1px" cellspacing="1px">
                    <tr><td>A</td><td>B</td><td >C</td><td >D</td><td>E</td><td>G</td><td>H</td>
                        <td>I</td><td>J</td><td >K</td><td >L</td><td>M</td><td>N</td><td>O</td>
                        <td>P</td><td>Q</td><td>R</td><td>S</td><td>T</td><td>U</td><td>V</td>
                        <td>W</td><td>X</td><td>Y</td><td>Z</td>
                    </tr>
                </table>
                <div class="product">  
                    <?php $thanhntt89 = 0;foreach ($products as $product) { $thanhntt89 ++;?>
                    <?php if ($product['thumb']) { ?>
                    <?php if($thanhntt89%3 == 1){?><ul class="product-item product-more"><?php }?>
                    <li <?php if($thanhntt89%3 == 1){echo 'class="item-first"'; }?>>
                        <div class="avata"><a class="fancybox" rel="fancybox" href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
                        <?php } ?>
                        <div class="name"><a href="<?php echo $product['href']; ?>"><span><?php echo $product['name']; ?></span></a></div>      
                        <?php if ($product['price']) { ?>
                        <?php if (!$product['special']) { ?>
                        <div class="price" ><?php echo $product['price']; ?></div>
                        <div class="old-price">&nbsp;</div>
                        <?php } else { ?>
                        <div class="price"><?php echo $product['special']; ?></div>
                        <div class="old-price"><?php echo $product['price']; ?></div>
                        <?php } ?>
                        <?php } ?>
                        <div class="btn">
                            <input type="text" class="qtty" name="quantity" size="2" />
                            <input type="hidden" name="product_id" size="2" value="<?php echo $product['product_id']; ?>" />
                            <input class="btn-buy" type="button" />                        </div>
                    </li>
                    <?php if($thanhntt89%3 == 0){?></ul><?php }?>
                    <?php } ?>
                </div> <!-- Endproduct -->
                <div class="pagination"><?php echo $pagination; ?></div>
                <?php if (!$categories && !$products) { ?>
                <div class="content"><?php echo $text_empty; ?></div>
                <div class="buttons">
                    <div class="right"><a href="<?php echo $continue; ?>" class="button"><span><?php echo $button_continue; ?></span></a></div>
                </div> <!-- end buttons-->
                <?php } ?>
            </div><!-- End content-->
            <?php echo $column_right; ?>
<!--            <div class="best-sell">
                <div class="best-sell-title">Sản phẩm mới</div>
                    <?php $thanhntt89 = 0; foreach ($products as $product){ $thanhntt89 ++;?>
                    <?php if($thanhntt89 == 1){?><ul><?php }?>
                    <?php if($thanhntt89 <= 3){?>
                        <li>
                            <div class="item-info">
                                <div class="name"><a href="#"><span><?php echo $product['name']; ?></span></a></div>
                                <div class="clear"></div>
                                <?php if ($product['price']) { ?>
                                <?php if (!$product['special']) { ?>
                                <div class="price" ><?php echo $product['price']; ?></div>
                                <div class="old-price">&nbsp;</div>
                                <?php } else { ?>
                                <div class="price"><?php echo $product['special']; ?></div>
                                <div class="old-price"><?php echo $product['price']; ?></div>
                                <?php } ?>
                                <?php } ?>
                            </div>
                            <div class="avata"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
                        </li>
                        <?php }else{?>
                            <div class="clear"></div>
                            <?php if($thanhntt89 == 4){?>
                                <ul class="show-product" style="overflow: hidden;height: 0px;">
                            <?php }?>
                            <li>
                                <div class="item-info">
                                    <div class="name"><a href="#"><span><?php echo $product['name']; ?></span></a></div>
                                    <div class="clear"></div>
                                    <?php if ($product['price']) { ?>
                                    <?php if (!$product['special']) { ?>
                                    <div class="price" ><?php echo $product['price']; ?></div>
                                    <?php } else { ?>
                                    <div class="price"><?php echo $product['special']; ?></div>
                                    <div class="old-price"><?php echo $product['price']; ?></div>
                                    <?php } ?>
                                    <?php } ?>
                                </div>
                                <div class="avata"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
                            </li>
                        <?php }?>
                    <?php if($thanhntt89 == 3){?></ul><?php }?>
                    <?php } ?>
                    </ul>
                    <div class="clear"></div>
                    <div class="btn-view-sell view">
                        <span>&nbsp;</span>
                        <input type="button"  value="Xem thêm" />
                        <span>&nbsp;</span>
                    </div>
                    <div class="clear"></div>
                    <div class="best-sell-title">Sản phẩm khuyến mãi</div>
                    <?php $thanhntt89 = 0; foreach ($products as $product){ $thanhntt89 ++;?>
                    <?php if($thanhntt89 == 1){?><ul><?php }?>
                    <?php if($thanhntt89 <= 3){?>
                        <li>
                            <div class="item-info">
                                <div class="name"><a href="#"><span><?php echo $product['name']; ?></span></a></div>
                                <div class="clear"></div>
                                <?php if ($product['price']) { ?>
                                <?php if (!$product['special']) { ?>
                                <div class="price" ><?php echo $product['price']; ?></div>
                                <div class="old-price">&nbsp;</div>
                                <?php } else { ?>
                                <div class="price"><?php echo $product['special']; ?></div>
                                <div class="old-price"><?php echo $product['price']; ?></div>
                                <?php } ?>
                                <?php } ?>
                            </div>
                            <div class="avata"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
                        </li>
                        <?php }else{?>
                            <div class="clear"></div>
                            <?php if($thanhntt89 == 4){?>
                                <ul class="show-product1" style="overflow: hidden;height: 0px;">
                            <?php }?>
                            <li>
                                <div class="item-info">
                                    <div class="name"><a href="#"><span><?php echo $product['name']; ?></span></a></div>
                                    <div class="clear"></div>
                                    <?php if ($product['price']) { ?>
                                    <?php if (!$product['special']) { ?>
                                    <div class="price" ><?php echo $product['price']; ?></div>
                                    <?php } else { ?>
                                    <div class="price"><?php echo $product['special']; ?></div>
                                    <div class="old-price"><?php echo $product['price']; ?></div>
                                    <?php } ?>
                                    <?php } ?>
                                </div>
                                <div class="avata"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
                            </li>
                        <?php }?>
                    <?php if($thanhntt89 == 3){?></ul><?php }?>
                    <?php } ?>
                    </ul>
                    <div class="clear"></div>
                    <div class="btn-view-sell view1">
                        <span>&nbsp;</span>
                        <input type="button"  value="Xem thêm" />
                        <span>&nbsp;</span>
                    </div>
            </div> End .best-sell -->
        </div> <!-- End content right-->
    </div>
    <?php echo $content_bottom; ?>
</div>

<script type="text/javascript">
    function display(view) {
    if (view == 'list') {
    $('.product-grid').attr('class', 'product-list');
		
    $('.product-list > div').each(function(index, element) {
    html  = '<div class="right">';
    html += '  <div class="cart">' + $(element).find('.cart').html() + '</div>';
    html += '  <div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
    html += '  <div class="compare">' + $(element).find('.compare').html() + '</div>';
    html += '</div>';			
			
    html += '<div class="left">';
			
    var image = $(element).find('.image').html();
			
    if (image != null) { 
    html += '<div class="image">' + image + '</div>';
}
			
var price = $(element).find('.price').html();
			
if (price != null) {
html += '<div class="price">' + price  + '</div>';
}
					
html += '  <div class="name">' + $(element).find('.name').html() + '</div>';
html += '  <div class="description">' + $(element).find('.description').html() + '</div>';
			
var rating = $(element).find('.rating').html();
			
if (rating != null) {
html += '<div class="rating">' + rating + '</div>';
}
				
html += '</div>';

						
$(element).html(html);
});		
		
$('.display').html('<b><?php echo $text_display; ?></b> <?php echo $text_list; ?> <b>/</b> <a onclick="display(\'grid\');"><?php echo $text_grid; ?></a>');
		
$.cookie('display', 'list'); 
}else{
$('.product-list').attr('class', 'product-grid');
		
$('.product-grid > div').each(function(index, element) {
html = '';
			
var image = $(element).find('.image').html();
			
if (image != null) {
html += '<div class="image">' + image + '</div>';
}
			
html += '<div class="name">' + $(element).find('.name').html() + '</div>';
html += '<div class="description">' + $(element).find('.description').html() + '</div>';
			
var price = $(element).find('.price').html();
			
if (price != null) {
html += '<div class="price">' + price  + '</div>';
}
			
var rating = $(element).find('.rating').html();
			
if (rating != null) {
html += '<div class="rating">' + rating + '</div>';
}
						
html += '<div class="cart">' + $(element).find('.cart').html() + '</div>';
html += '<div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
html += '<div class="compare">' + $(element).find('.compare').html() + '</div>';
			
$(element).html(html);
});	
					
$('.display').html('<b><?php echo $text_display; ?></b> <a onclick="display(\'list\');"><?php echo $text_list; ?></a> <b>/</b> <?php echo $text_grid; ?>');
		
$.cookie('display', 'grid');
}
}

view = $.cookie('display');

if (view) {
display(view);
} else {
display('list');
}
</script> 

<script type="text/javascript"><!--
$('.btn-buy').bind('click', function() {
	$.ajax({
		url: 'index.php?route=checkout/cart/update',
		type: 'post',
		data: $(this).parent().find('input[type=\'text\'], input[type=\'hidden\']'),
		dataType: 'json',
		success: function(json) {
			$('.success, .warning, .attention, information, .error').remove();
			
			if (json['error']) {
				if (json['error']['warning']) {
					$('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
				
					$('.warning').fadeIn('slow');
				}
				
				for (i in json['error']) {
					$('#option-' + i).after('<span class="error">' + json['error'][i] + '</span>');
				}
			}	 
						
			if (json['success']) {
				$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
					
				$('.success').fadeIn('slow');
					
				$('#cart_total').html(json['total']);
				
				$('html, body').animate({ scrollTop: 0 }, 'slow'); 
			}	
		}
	});
});
//--></script>
<script type="text/javascript"><!--
$('#content input[name=\'filter_name\']').keydown(function(e) {
	if (e.keyCode == 13) {
		$('#text-search').trigger('click');
	}
});

$('#text-search').bind('click', function() {
	url = 'index.php?route=product/search';
	
	var filter_name = $('#content input[name=\'filter_name\']').attr('value');
	
	if (filter_name) {
		url += '&filter_name=' + encodeURIComponent(filter_name);
	}

	var filter_category_id = $('#content select[name=\'filter_category_id\']').attr('value');
	
	if (filter_category_id > 0) {
		url += '&filter_category_id=' + encodeURIComponent(filter_category_id);
	}
	
	var filter_sub_category = $('#content input[name=\'filter_sub_category\']:checked').attr('value');
	
	if (filter_sub_category) {
		url += '&filter_sub_category=true';
	}
		
	var filter_description = $('#content input[name=\'filter_description\']:checked').attr('value');
	
	if (filter_description) {
		url += '&filter_description=true';
	}

	location = url;
});
--></script> 
<?php echo $footer; ?>
